Skip to content

feat: add cost details to chat completion usage#196

Open
akicool wants to merge 1 commit into
OpenRouterTeam:mainfrom
akicool:main
Open

feat: add cost details to chat completion usage#196
akicool wants to merge 1 commit into
OpenRouterTeam:mainfrom
akicool:main

Conversation

@akicool

@akicool akicool commented Mar 1, 2026

Copy link
Copy Markdown
  • Extend ChatGenerationTokenUsage with cost, isByok, and costDetails fields to expose pricing information returned by the OpenRouter API. Matches the actual API response shape (upstream_inference_prompt_cost / upstream_inference_completions_cost).

- Extend ChatGenerationTokenUsage with cost, isByok, and costDetails fields
to expose pricing information returned by the OpenRouter API. Matches the
actual API response shape (upstream_inference_prompt_cost /
upstream_inference_completions_cost).
@the-dream-machine

Copy link
Copy Markdown

Is it possible to extend this to return costs for the embedding endpoints as well?

@akicool

akicool commented Mar 3, 2026

Copy link
Copy Markdown
Author

Is it possible to extend this to return costs for the embedding endpoints as well?

Yep, it make sense btw, I'll try to add this

@akicool

akicool commented Mar 4, 2026

Copy link
Copy Markdown
Author

Is it possible to extend this to return costs for the embedding endpoints as well?

As far as I understand, we can't get information about costs_details in the response data, but we do have a cost field in the response from the embeddings endpoint.

@the-dream-machine

the-dream-machine commented Mar 14, 2026

Copy link
Copy Markdown

As far as I understand, we can't get information about costs_details in the response data, but we do have a cost field in the response from the embeddings endpoint.

Yes, this is true. The cost_details contains information about the upstream provider cost for BYOK. I don't think BYOK is supported yet for embedding providers.

@marcroberts

Copy link
Copy Markdown

Any chance of getting this updated and merged in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants